﻿//using System;
//using System.Configuration;
//using System.Text;
//using Giraffe.Core.Common;
//using Microsoft.Practices.Composite.Logging;
//using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
//using Microsoft.Practices.EnterpriseLibrary.PolicyInjection;
//using Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration;
//using Microsoft.Practices.Unity.InterceptionExtension;

//namespace Giraffe.Core.Instrumentation
//{
//// ReSharper disable UnusedMember.Global
//    [ConfigurationElementType(typeof(MethodLoggingCallHandlerData))]

//    public class MethodLoggingCallHandler: ICallHandler
//// ReSharper restore UnusedMember.Global
//    {
//        public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
//        {
//            bool isDebugMode = bool.Parse(ConfigurationManager.AppSettings["DebugMode"]);
//            if (isDebugMode)
//            {
//                StringBuilder sb = new StringBuilder();
//                sb.Append("Method {0} was invoked.");
                
//                IParameterCollection parameterCollection = input.Arguments;
//                for (int i = 0; i < parameterCollection.Count; i++)
//                {
//                    object parameterValue = parameterCollection[i];
//                    sb.AppendFormat("{0} : {1}", parameterCollection.GetParameterInfo(i).Name,
//                                    parameterValue ?? "[NULL]");
//                }

//                ILoggerFacade logger = ObjectProvider.Resolve<ILoggerFacade>();
//                logger.Log(sb.ToString(), Category.Debug, Priority.High);
//            }
            
//            return getNext()(input, getNext);
//        }

//        public int Order
//        {
//            get; set;
//        }
//    }

//    public class MethodLoggingCallHandlerData : CallHandlerData
//    {
//    }
//}
